//
//  JYNetworkTool.swift
//  01.weibo
//
//  Created by 谢玉锋 on 16/7/11.
//  Copyright © 2016年 itheima.cn. All rights reserved.
//

import UIKit
import AFNetworking

enum HMNetworkErrorEnum: Int {

    case AccessTokenEmpty = -1
    case UidEmpty = -2
    case RepeatLoadStatus = -3
    var errorDescription: String {
        get {
            switch self {
                case AccessTokenEmpty: return "access_token没有值"
                case UidEmpty: return "uid没有值"
                case RepeatLoadStatus: return "正在加载数据中"
            }
        }
    }
    // domain: 自定义: 表示错误范围
    // code: 自定义: 表示错误类型,一般是以负数开头
    // userInfo: 附加的信息
    func error() ->NSError {
        return NSError(domain: "cn.itheima.net", code: self.rawValue, userInfo: ["errorDescription": self.errorDescription])
    }

}

class JYNetworkTool: AFHTTPSessionManager {

    static let shareInstance: JYNetworkTool = {
        var tool = JYNetworkTool()
        tool.responseSerializer.acceptableContentTypes?.insert("text/plain")
        return tool
    }()
}
